package com.demo376_摆动序列;

public class Solution_无敌 {
    public static void main(String[] args) {
        int[] ints = {1,17,5,10,13,15,10,5,16,8};
        int i = wiggleMaxLength(ints);
        System.out.println(i);
    }

    public static int wiggleMaxLength(int[] nums) {
        /*if (nums.length==1){
            return 1;
        }*/      // 这里都不用加判断, 如果是1的话, 下面的循环就直接是不符合, 结果还是1
        int up=1;
        int down=1;
        for (int i = 1; i < nums.length; i++) {
            if(nums[i]>nums[i-1]){
                up=down+1;
            }else if (nums[i]<nums[i-1]){
                down=up+1;
            }
        }
        return Math.max(up,down);
    }
}
